package com.zach.common.service.impl;

import java.io.Serializable;
import java.util.List;

import org.springframework.context.annotation.Scope;
import org.springframework.context.annotation.ScopedProxyMode;
import org.springframework.stereotype.Service;

import com.zach.common.dao.UserDao;
import com.zach.common.entity.User;
import com.zach.common.service.UserService;

@Service("userService")
@Scope(value="singleton",proxyMode=ScopedProxyMode.INTERFACES)
public class UserServiceImpl implements UserService, Serializable {
	private static final long serialVersionUID = 3513803998412253995L;
	private UserDao userDao;
	@Override
	public User getUserById(String userId) {
		return userDao.getUser(userId);
	}

	@Override
	public User getUser(String loginName) {
		return userDao.getUserByLoginName(loginName);
	}

	@Override
	public List<User> getUserListByUser(User user) {
		return userDao.getUserListByUser(user);
	}
	

	@Override
	public List<User> getUserListByUser(User user, Integer pageSize,
			Integer pageNo) {
		if(null == pageNo && null == pageSize){
			return userDao.getUserListByUser(user);
		}
		return userDao.getUserListByUser(user,pageSize,pageNo);
	}

	@Override
	public void addUser(User user) {
		userDao.addUser(user);
	}

	@Override
	public void updateUser(User u) {
		userDao.updateUserByLoginName(u);
	}

	@Override
	public void updateUserById(User u) {
		userDao.updateUser(u);
	}

	@Override
	public void deleteUserById(String userId) {
		userDao.deleteUserById(userId);
	}

	@Override
	public void deleteUser(String loginName) {
		userDao.deleteUserByLoginName(loginName);
	}

	public UserDao getUserDao() {
		return userDao;
	}
	
	public void setUserDao(UserDao userDao) {
		this.userDao = userDao;
	}
}
